<?php 
$isOpen = Configure::read('Delivery.is_open');
$this->pageTitle = "Member Menu";

if($current_user['auth_type'] == 'administrator') {
  
?>
<h1>Administrator Menu</h1>
<div class="info">
<?php
if ($isOpen) {
  echo "Ordering is still open.";
} else {
  echo "Ordering is closed.";
}
?>
</div>
<h2>Member Functions</h2>
<ul>
<li>Search:
<form action="<?=$html->url('/members/search')?>" method="POST">
	<select name="data[Member][field]">
		<option value="last_name">Last Name</option>
		<option value="first_name">First Name</option>
		<option value="email_address">Email</option>
	</select>
	<input type="text" name="data[Member][value]"/>
	<input type="submit"/>
</form></li>
<h3>Lists</h3>
<h4>By User Type</h4>
<li><?=$html->link('User List', '/members/show'); ?></li>
<li><?=$html->link('Member List', '/members/show/votes'), ', ', $html->link('[Contact Sheet]', '/members/show/votes/1/contact'); ?></li>
<li><?=$html->link('Volunteer List', '/members/show/volunteer'), ', ', $html->link('[Contact Sheet]', '/members/show/volunteer/1/contact')?></li>
<li><?=$html->link('Producer List', '/members/show/producer'), ', ', $html->link('[Contact Sheet]', '/members/show/producer/1/contact'); ?></li>
<li><?=$html->link('Route Manager List', '/members/show/rtemanager'); ?></li>
<li><?=$html->link('Cashier List', '/members/show/cashier'); ?></li>
<li><?=$html->link('Administrator List', '/members/show/administrator'), ', ', $html->link('[Contact Sheet]', '/members/show/administrator/1/contact'); ?></li>
<h4>By Fee Status</h4>
<li><?=$html->link('Paid List', '/members/show/paid'); ?></li>
<li><?=$html->link('Unpaid List', '/members/show/unpaid'); ?></li>
<li><?=$html->link('Coming Due List', '/members/show/due'); ?></li>
<h3>Invites</h3>
<li><?=$html->link('Invite New User', '/invites/send'); ?></li>
</ul>

<h2>Order Cycle Functions</h2>
<ul>
<?php
if (!$isOpen) {
  echo '<li>'. $html->link('View All Invoices','/basketItems/showAll') . '</li>' . "\n";
}
?>
<li><?=$html->link('Order Cycle Statistics', '/pages/stats'); ?></li>
</ul>
<h2>Mail Functions</h2>
<ul>
<li><?=$html->link('Mass Mailer...', '/members/messenger'); ?></li>
<li><?=$html->link('Mailing Labels for Producers [PDF Download]','/producers/labelsForAdmin');?></li>
<li><?=$html->link('Mailing Labels for Users [PDF Download]','/members/labelsForAdmin');?></li>
</ul>
<h2>Misc.</h2>
<ul>
<li><?=$html->link('Add Subcategory','/subcategories/add');?></li>
<li><?=$html->link('View Producer Privs Requests', '/producerRequests/view');?></li>
</ul>
<?php 
}
if (isset($current_user['board_mem']) && $current_user['board_mem']) {
?>
<h1>Board Member Menu</h1>
<ul>
<li><?=$html->link('Board Member List', '/members/show/board'); ?></li>
</ul>
<?php
} 
if(in_array($current_user['auth_type'],array('administrator','producer'))) {
  //producer menu
?>
<h1>Producer Menu</h1>
<ul>
<?php 
if ($current_user['auth_type'] == AUTH_PROD) {
?>
<p>We've added a new URL (web address) for members to get to your about page, and it looks like this:</>
<p><a href="http://www.westmichigancoop.com/about/<?=$current_user['username']?>">http://www.westmichigancoop.com/about/<?=$current_user['username']?></a></p>
<p>Feel free to advertise that, or link to it from other sites!  If you were already linking to your about page
elsewhere, don't worry: the old links will continue to work for the foreseeable future.</p>
<h2>Business Information</h2>
<li><?=$html->link('Update Business Contact Info...','/members/editProducer');?></li>
<li><?=$html->link('Update Business Details...','/producers/changeInfo/' . $current_user['producer_id']);?></li>
<h2>Product Information</h2>
<li><?=$html->link('Add a Product','/products/add');?></li>
<li><?=$html->link('Manage Products','/products/manage');?></li>
<li><?=$html->link('View Orders...','/producers/invoicing/' . $current_user['producer_id']);?></li>
<?php if (!$isOpen) { 
	echo '<li>' . $html->link('Check In...','/producers/setupForCheckIn/' . $current_user['producer_id']) . '</li>'; 
	echo '<li>'. $html->link('Labels for Orders [PDF Download]','/producers/labelsForProducer/' . $current_user['producer_id']) . '</li>';
}

}
?>
</ul>
<?php
} 
if(in_array($current_user['auth_type'],array('administrator','rtemanager'))) {
  //rtemanager menu
?>
<h1>Route Manager Menu</h1>
<?php 
} 
if(in_array($current_user['auth_type'],array('administrator','cashier'))) {
  //cashier menu
  App::import('Model', 'BasketItem');
  $b = new BasketItem();
  $baskets = $b->numBaskets();
  $producers = $b->numProducers();
?>
<h1>Cashier Menu</h1>
<ul>
<li><?=$html->link('Mailing Labels for Producers [PDF Download]','/producers/labelsForCashier');?></li>
<li><?=$html->link('Invoice Notes for This Cycle', '/notes/view'); ?></li>
<?php
for ($i = 1; $i <= ceil($producers / 10); $i++) {
	$top = ($i * 10 > $producers) ? $producers : $i * 10;
	echo '<li>', $html->link('Producer Invoices ' . (($i - 1) * 10 + 1) . ' - ' . $top,'/basketItems/showAll/producer/' . $i), ', ' , $html->link('[PDF]','/basketItems/showAll/producer/' . $i . '.pdf'), '</li>';
}
for ($i = 1; $i <= ceil($producers / 10); $i++) {
	$top = ($i * 10 > $producers) ? $producers : $i * 10;
	echo '<li>', $html->link('Producer Reports ' . (($i - 1) * 10 + 1) . ' - ' . $top,'/producers/reports/' . $i), ' (PDF)</li>';
}
for ($i = 1; $i <= ceil($baskets / 50); $i++){
	$top = ($i * 50 > $baskets) ? $baskets : $i * 50;
	echo '<li>', $html->link('Member Invoices ' . (($i - 1) * 50 + 1) . ' - ' . $top,'/basketItems/showAll/member/' . $i), ', ', $html->link('[PDF]','/basketItems/showAll/member/' . $i . '.pdf'), '</li>';
}
for ($i = 1; $i <= ceil($baskets / 40); $i++){
	echo '<li>', $html->link('Cashier Checklist ' . $i,'/members/checklist/' . $i), '</li>';
}
?>
</ul>
<?php 
} 
if(in_array($current_user['auth_type'],array('administrator','producer','rtemanager','cashier','member'))) {
  //member menu
?>
<h1>User Menu</h1>
<p><?=$html->link('Invite a Friend to the Co-op', '/members/invite');?> <em>New!</em></p>
<h2>Shopping</h2>
<ul>
<?php 
  if (!$isOpen) {
?>
<li>Ordering is currently closed.</li>
<li><?=$html->link("See products by category",'/categories');?></li>
<li><?=$html->link("See products by producer",'/producers');?></li>
<?php
  } else {
?>
<li><?=$html->link("Shop by category",'/categories/view');?></li>
<li><?=$html->link("Shop by producer",'/producers/view');?></li>
<?php
  }
?>
<li><?=$html->link("New Products",'/products/view/new');?></li>
<li><?=$html->link("Updated Products",'/products/view/changed');?></li>
<li><?=$html->link("Basic Search",'/products/basicSearch');?></li>
<li><?=$html->link("My Favorites...",'/favorites/view/' . $current_user['username']);?></li>
</ul>
<h2>Basket</h2>
<ul>
<li><?=$html->link("Manage My Basket...",'/members/basket');?></li>
</ul>
<h2>Preferences</h2>
<ul>
<li><?=$html->link('Update Contact Info...','/members/edit');?></li>
<?php if($current_user['auth_type']=='member') { 
  ?>
<li><?=$html->link('Request Producer Privileges','/producerRequests/send');?></li>
<?php } ?>
</ul>
<?php 
} // generic menus under here.
?>
